package com.tenement.controller;


import com.tenement.common.Axios;
import com.tenement.entity.Idle;
import com.tenement.vo.QueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import com.tenement.service.IdleService;

import java.util.List;


/**
 *  控制层。
 *
 * @author BertXie
 * @since 1.0.1
 */
@RestController
@RequestMapping("/idle")
@RequiredArgsConstructor
@Api(tags = "闲置管理接口")
public class IdleController {

    private final IdleService idleService;


    @ApiOperation(value = "闲置数据列表")
    @PostMapping("list")
    public Axios list(QueryVo queryVo) {
        return Axios.success(idleService.list(queryVo));
    }

    @ApiOperation(value = "操作闲置数据")
    @PutMapping("operator")
    public Axios operator(Idle idle) {
        return Axios.success(idleService.saveOrUpdate(idle));
    }

    @ApiOperation(value = "删除闲置数据")
    @DeleteMapping("remove")
    public Axios remove(@RequestBody List<Long> ids) {
        return Axios.success(idleService.removeByIds(ids));
    }

}
